﻿using System;
class CatalanNumber
{
    static void Main()
    {
        int number;
        int catalan;
        double numerator = 1d;
        double denominatorone = 1d;
        double denominatortwo = 1d;
        Console.Write("Please enter number of Catalan member: ");
        do
        {
            while (true)
            {
                try
                {
                    number = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number:");
                }
            }
        } while (number <= 0);
        for (int i = 1; i <= number * 2; i++)
        {
            numerator = numerator * i;
        }
        for (int i = 1; i <= number; i++)
        {
            denominatortwo = denominatortwo * i;
        }
        for (int i = 1; i <= (number + 1); i++)
        {
            denominatorone = denominatorone * i;
        }
        Console.WriteLine("N = {0}",number);
        Console.WriteLine("If Cn = 2*n!/(n+1)!*n! , then");
        Console.WriteLine("The C{0} member is: 2*{0}!/({0}+1)!*{0}! = {1}", number, (numerator / (denominatorone * denominatortwo)));
        Console.ReadLine();
    }
}

